package me.jessyan.armscomponent.app.di.module;

import android.view.View;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.jess.arms.base.DefaultAdapter;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.utils.ArmsUtils;

import java.util.ArrayList;
import java.util.List;

import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import me.jessyan.armscomponent.app.mvp.contract.mine.MineLearningListContract;
import me.jessyan.armscomponent.app.mvp.model.mine.MineLearningListModel;
import me.jessyan.armscomponent.app.mvp.model.entity.LearnItem;
import me.jessyan.armscomponent.app.mvp.ui.adapter.MineLearnListAdapter;


/**
 * <p>
 * Author: Taozebi
 * Date: 09/08/2021 20:49
 * Description: describe of this class
 */
@Module
public abstract class MineLearningListModule {

    @Binds
    abstract MineLearningListContract.Model bindMineLearningListModel(MineLearningListModel model);


    @ActivityScope
    @Provides
    static RecyclerView.LayoutManager provideLayoutManager(MineLearningListContract.View view) {
        return new LinearLayoutManager(view.getActivity());
    }

    @ActivityScope
    @Provides
    static List<LearnItem> provideList() {
        return new ArrayList<>();
    }

    @ActivityScope
    @Provides
    static RecyclerView.Adapter provideMineHistoryAdapter(MineLearningListContract.View mineHistoryView,List<LearnItem> list) {
        MineLearnListAdapter adapter = new MineLearnListAdapter(list);
        adapter.setOnItemClickListener(new DefaultAdapter.OnRecyclerViewItemClickListener<LearnItem>() {
            @Override
            public void onItemClick(@NonNull View view, int viewType, @NonNull LearnItem data, int position) {
                ArmsUtils.snackbarText("position:"+position);
            }
        });
        return adapter;
    }

}